package com.example.houduan.Mapper;

import com.example.houduan.Pojo.City;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CityMapper {
    @Select("select * from city limit #{b}, #{e}")
    List<City> selectCityLimit(int b, int e);
    
    @Select("select * from city where (#{city_id} is null or city_id = #{city_id}) and (#{city_name} is null or #{city_name} = '' or city_name like concat('%', #{city_name}, '%'))")
    List<City> selectCityByConditions(Integer city_id, String city_name);

    @Select("select count(*) from city")
    int selectCityCount();
    
    @Delete("delete from city where city_id = #{city_id}")
    int deleteCity(int city_id);

    @Insert("insert into city(city_name) values (#{city_name})")
    int insertCity(City city);

    @Update("update city set city_name = #{city_name} where city_id = #{city_id}")
    int updateCity(City city);

    @Select("select * from city")
    List<City> selectCityList();
}
